<?php
namespace app\common\server;
use app\common\model\Infinite;
use app\common\model\OneGoods;
use app\common\model\OneGoodsList;
use app\common\model\OneOrderList;
use \think\facade\Db;
use app\api\Controller\Base;
use app\common\model\User;

class Order {
    /**
     * 查询物流信息
     */

    public function getcourier($no,$express_name=''){
        $host = "https://kdcx.market.alicloudapi.com";
        $path = "/express";
        $method = "POST";
        $appcode = getConfig('base')['logistics_code'];
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $appcode);
        $querys = "express_id=".$no."&express_name=".$express_name;
        $bodys = "";
        $url = $host . $path . "?" . $querys;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        if (1 == strpos("$".$host, "https://"))
        {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }

        $out_put = curl_exec( $curl );
        $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        list($header, $body) = explode("\r\n\r\n", $out_put, 2);

        $body = json_decode($body,true);
        return $body;
    }
}